<?php
session_start();
require_once("../config/include_tokyo.inc.php");
require_once("../class/Common_Function.php");


//访问权限验证
$userId = $_SESSION['user_id'];
$userRole = $_SESSION['user_role'];
if($userRole == 1 || $userRole == 8){
	//管理员 || 团队成员
}else{
	if($userRole > 0){
		$url = "../index.php?loginError=2";//没权限
	}else{
		$url = "../index.php?loginError=3";//没登录
	}	
	echo "<script language='javascript' type='text/javascript'>";
	echo "window.location.href='$url'";
	echo "</script>";
}


//项目报告
$id = $_GET['id'];
$fromflag = $_GET['fromflag'];//哪里跳转过来的
if($id == ""){
	echo "该项目不存在！";
}else{
	$sql = "SELECT * from teamproject where id=".$id;
	$result = $db->Execute($sql);
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<!--Begin:head-->
<? $pageTitle = "项目报告"; ?>
<?php include("../head.php"); ?>
<!--End:head-->


<body>
<?php include("../topMenu.php"); ?>

<?php 
if($fromflag == "my"){
	include("myteamMenu.php");
}else{
	include("teamMenu.php");
} 
?>


<form name="inputForm" action="../team/teamProjectInput.php" method="post">
<div id="container" >	
<div class="grayTable">	
<h4>项目报告</h4>
<table >
<thead>
	<tr>
		<th scope="col" >字段名称</th>
	    <th scope="col" >字段值</th>		
	</tr>
</thead>

<?php
	if(!$result->EOF){
		$commonFunction = new Common_Function();
		//********项目项目负责人*************
		$user_sql = "SELECT * from users where id=".$result->fields['project_owner'];
		$user_result = $db->Execute($user_sql);
		if(!$user_result->EOF){
			$userName = $user_result->fields['user_name'];
		}
		//********Display*************
		$strTR = "";
		$strTR = $strTR."<tr ><td>项目编号</td>";
		$strTR = $strTR."<td>".$result->fields['id']."</td></tr>";
		$strTR = $strTR."<tr ><td>创建时间</td>";
		$strTR = $strTR."<td>".$result->fields['create_time']."</td></tr>";
		$strTR = $strTR."<tr ><td>项目名称</td>";
		$strTR = $strTR."<td>".$result->fields['project_name']."</td></tr>";
		$strTR = $strTR."<tr ><td>项目描述</td>";
		$strTR = $strTR."<td>".$result->fields['project_description']."</td></tr>";
		$strTR = $strTR."<tr ><td>项目计划</td>";
	    $strTR = $strTR."<td>".$result->fields['project_plan']."</td></tr>";
		$strTR = $strTR."<tr ><td>风险评估</td>";
		$strTR = $strTR."<td>".$result->fields['project_risk']."</td></tr>";
		$strTR = $strTR."<tr ><td>开始时间</td>";
		$strTR = $strTR."<td>".$result->fields['begin_time']."</td></tr>";
		$strTR = $strTR."<tr ><td>完成时间(预期)</td>";
		$strTR = $strTR."<td>".$result->fields['expect_end_time']."</td></tr>";
		$strTR = $strTR."<tr ><td>项目等级</td>";
		$strTR = $strTR."<td>".$commonFunction->getProjectLevelName($result->fields['project_level'])."</td></tr>";	
		$strTR = $strTR."<tr ><td>项目状态</td>";
		$strTR = $strTR."<td>".$commonFunction->getProjectStatusName($result->fields['project_status'])."</td></tr>";			
		$strTR = $strTR."<tr ><td>项目总结</td>";
		$strTR = $strTR."<td>".$result->fields['project_summary']."</td></tr>";
		$strTR = $strTR."<tr ><td>结束时间</td>";
		$strTR = $strTR."<td>".$result->fields['close_time']."</td></tr>";
		$strTR = $strTR."<tr ><td>项目负责人</td>";
		$strTR = $strTR."<td>".$userName."</td></tr>";
		$strTR = $strTR."<tr><td colspan=2 align=center>";
		if($fromflag == "my"){
			$strTR = $strTR."<input type='button' value='返回列表' onClick='toMyList()'>";
		}else{			
			$strTR = $strTR."<input type='button' value='编辑' onclick='doEdit(".$result->fields['id'].")'> &nbsp;&nbsp;";
			$strTR = $strTR."<input type='button' value='返回列表' onClick='toList()'>";		
		}		
		$strTR = $strTR."</td></tr>";
		echo $strTR;
  }
?>

</table>

<br><br>
<h4>项目进展记录</h4>
<table >
<thead>
	<tr>
		<th scope="col">时间</th>
	    <th scope="col" >进展内容</th>		
	</tr>
</thead>
<tbody>
<?php
	$sql = "SELECT  * from teamprojectprocess where project_id=".$id." order by modifytime asc";	
	$resultProcess = $db->Execute($sql);		
	while (!$resultProcess->EOF) {		
		$strTR = "";
		$strTR = $strTR."<tr ><td>".$resultProcess->fields['modifytime']."</td>";
		$strTR = $strTR."<td>".$resultProcess->fields['project_process']."</td></tr>";
		echo $strTR;
		$resultProcess->MoveNext();	
	}	
?>
</tbody>

</table>

</div>

<br><br>
<br><br>

</div><!--end container -->

</form>
</body>




</html>

<script>



/************返回列表**************************/
function toList(){
	window.location.href = "teamProject.php";
}


/************返回我的列表**************************/
function toMyList(){
	window.location.href = "myProject.php";
}



/************编辑项目**************************/
function doEdit(id){
	 window.location.href="teamProjectInput.php?id="+id; 
}


</script>